package com.zgis.module.db.service.impl;

import com.zgis.module.bas.bean.CxSqlExp;
import com.zgis.module.bas.bean.CxSqlPro;
import com.zgis.module.db.interfaces.ICxSqlExp;
import com.zgis.module.db.service.RedisCacheService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Redis版本的SqlExp管理实现
 */
@Slf4j
@Service("redisCxSqlExpImpl")
public class RedisCxSqlExpImpl implements ICxSqlExp
{

    @Resource
    private RedisCacheService redisCacheService;

    @Override
    public CxSqlExp queryCxSqlExp(String name) throws Exception {
        CxSqlExp sqlExp = redisCacheService.getSqlExpByName(name);
        if (sqlExp == null) {
            throw new Exception("未找到SqlExp: name=" + name);
        }
        return sqlExp;
    }

    @Override
    public CxSqlPro queryCxSqlPro(String name) throws Exception {
        CxSqlPro sqlPro = redisCacheService.getSqlProByName(name);
        if (sqlPro == null) {
            throw new Exception("未找到SqlPro: name=" + name);
        }
        return sqlPro;
    }
}
